package com.clock.controller.stage;

import com.clock.common.domain.R;
import com.clock.domain.entity.User;
import com.clock.domain.vo.StudyAnalysisVo;
import com.clock.service.StudyAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = {"用户学习情况分析接口--只允许用户本人访问"})
@RestController
@RequestMapping("userStudyAnalysis")
public class StudyAnalysisController {

    @Resource
    StudyAnalysisService studyAnalysisService;

    @ApiOperation(value = "获取用户学习情况分析", notes = "只需要用户id")
    @PostMapping("getStudyAnalysis")
    public R getStudyAnalysis(@RequestBody User user) {
        StudyAnalysisVo studyAnalysis = studyAnalysisService.getStudyAnalysis(user);
        if(studyAnalysis.getSignAmount() == null || studyAnalysis.getSignAmount() < 7){
            return R.fail("888","签到满七天才可以解锁当月学习情况");
        }
        return R.ok(studyAnalysis);
    }

    @ApiOperation(value = "获取用户身上的标签信息", notes = "只需要用户id")
    @PostMapping("getUserInfTag")
    public R getUserInfTag(@RequestBody User user) {
        String[] userInfTag = studyAnalysisService.getUserInfTag(user);
        if(userInfTag.length<=0 || (userInfTag[0] ==null && userInfTag[1] == null)){
            return R.fail("888","没有相关标签信息");
        }
        return R.ok(userInfTag);
    }


}
